package com.rpc;

import com.oildatacollection.server.Server;
import javafx.util.Pair;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.List;
import java.util.Map;

public class OilInfoSendImpl extends UnicastRemoteObject implements OilInfoSend {
    private Server server;

    public OilInfoSendImpl(Server server) throws RemoteException {
        this.server = server;
    }

    @Override
    public boolean wellControlData(int wellID, byte[] data) throws RemoteException {
        // 查看当前的socke连接是否存在
        if (data.length != 2) {
            return false;
        }
        server.sendMessage(wellID, data);
        return true;
    }

    @Override
    public void setIpAllowed(List<Pair<String, Boolean>> ips) throws RemoteException {
        for (Pair<String, Boolean> item : ips) {
            server.changeIpSet(item.getKey(), item.getValue());
        }
    }
}
